<!--
 * @Author: Pure <305737824@qq.com>
 * @CreateTime: 2021-08-17 16:56:58
 * @LastEditors: Pure <305737824@qq.com>
 * @LastEditTime: 2021-08-17 17:12:15
 * @Description:单元树型控件
-->
<template>
  <el-tree
    :data="treeData"
    :props="defaultProps"
    node-key="id"
    accordion
    highlight-current
    v-bind="$attrs"
    v-on="$listeners"
  />
</template>

<script>
import InspectionUnitApi from '@/apis/inspection/unit';
export default {
  name: 'PureInspectionUnitTree',
  data() {
    return {
      treeData: [],
      defaultProps: {
        children: 'children',
        label: 'name',
      },
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    async fetchData() {
      try {
        const list = await InspectionUnitApi.tree();
        this.treeData = list;
      } catch (error) {
        this.$message({
          type: 'error',
          message: error,
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>

</style>
